package com.cloud.salon.client.menber.controller;

import com.cloud.salon.client.menber.service.AccountService;
import com.cloud.salon.common.base.response.Res;
import com.cloud.salon.common.base.entity.menber.Account;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description 顾客管理控制器
 * @Author wolf--LZH
 * @CreateDate 2019/4/10 0010 下午 1:30
 */
@RestController
@RequestMapping("account")
@Api(tags = "会员账户相关接口")
public class AccountController {

    private final String name = "会员账户";

    @Autowired
    private AccountService service;

    @PostMapping("findById")
    @ApiOperation(value="通过id查找一个" + name)
    public Res<Account> findById(@RequestBody Integer id) {
        return service.findById(id);
    }

    @PostMapping("findAll")
    @ApiOperation(value="获取所有的" + name)
    public Res<List<Account>> findAll() {
        return service.findAll();
    }

    @PostMapping("setBalance")
    @ApiOperation(value="以增量的方式设置会员的余额")
    public Res<Integer> setBalance(@RequestBody Account account) {
        return service.setBalance(account);
    }

    @PostMapping("save")
    @ApiOperation(value="添加一个" + name)
    public Res<Account> save(@RequestBody Account account) {
        return service.save(account);
    }

    @PostMapping("saveAll")
    @ApiOperation(value="批量添加" + name)
    public Res<List<Account>> saveAll(@RequestBody List<Account> accounts) {
        return service.saveAll(accounts);
    }

//    @PostMapping("update")
//    @ApiOperation(value="修改" + name + "数据")
//    public Res<Account> update(@RequestBody Account account) {
//        return service.update(account);
//    }
//
//    @PostMapping("updateAll")
//    @ApiOperation(value="批量修改" + name + "数据")
//    public Res<List<Account>> updateAll(@RequestBody List<Account> accounts) {
//        return service.updateAll(accounts);
//    }

    @PostMapping("deleteById")
    @ApiOperation(value="通过id删除对应" + name)
    public Res<Boolean> deleteById(@RequestBody Integer id) {
        return  service.deleteById(id);
    }

    @PostMapping("deleteByIdAll")
    @ApiOperation(value="通过id集合批量删除" + name)
    public Res<Integer> deleteByIdAll(@RequestBody List<Integer> ids) {
        return service.deleteByIdAll(ids);
    }
}
